<?php
if(!defined('APP_RUN')) exit();

if (!$config['global']['path']) {
	define('PATH', $config['global']['path']);
} else {
	define('PATH', '/' . $config['global']['path']);
}

define('TEMPLATE', PATH . '/system/templates');

/* *todo*
 * caching result or select form mysql
 */
$sock = @fsockopen('127.0.0.1', $config['server']['port'], $errno, $errstr, $config['status']['timeout']);

if ($sock) {
	$config['status']['online'] = true;
	preg_match('/uptime="(\d+)"/', $data, $matches);
	$h = floor($matches[1] / 3600);
	$m = floor(($matches[1] - $h * 3600) / 60);
	$config['status']['uptime'] = $h . 'h ' . $m . 'm';
} else {
	$config['status']['online'] = false;
	$config['status']['uptime'] = 0;
}

$status = (false == $config['status']['online']) ? 'offline' : 'online';
$color = ('online' == $status) ? 'green' : 'red';

define('COLOR', $color);
define('STATUS', $status);

/*
Changing the  value  of  this  definition  (FOOTER)  to
something that does not include the  name  of  the  AAC
will lead to instant banishment  of  this  server  from
the archez aac database and fast pass to the black list.
*/

define('FOOTER', 'Archez AAC 1.0');

define('UPTIME', $config['status']['uptime']);
if (isset($_SESSION['logged'])) {
	define('LOGGED', true);
} else {
	define('LOGGED', false);
}
?>